home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
fractals
/
apfelkiste
/
apfelkiste2.0
/
source
/
apfelkiste2.0src.lzh
/
Apfelkiste.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-23
|
28KB
|
1,041 lines
/************************************************************************/
/* Apfel.c --- Generates an image of the Mandelbrot-set */
/* */
/* Author: M. Böhnisch (BillySoft) */
/* Löher Str. 2 */
/* D-4790 Paderborn */
/* */
/* billy@uni-paderborn.de.pbinfo */
/*======================================================================*/
/* 06.11.89 iterative version with fixed box sizes (10 by 10), */
/* adapted a GFA-BASIC program from a german magazine */
/* */
/* 08.11.89 complete own version with recursive algorithm */
/* (divide & conquer) */
/* */
/* 10.11.89 added user input of picture size and borders */
/* */
/* 11.11.89 minor bug fixing */
/* */
/* 20.11.89 added fix-point arithmetik written in assembler */
/* format: */
/* */
/* [sgn|xxx xxxx xxxx xxxx.xxxx xxxx xxxx xxxx] */
/* */
/* not accurate enough. */
/* */
/* 21.11.89 rewrote fix-point format to: */
/* */
/* [sgn|xxx xxxx.xxxx xxxx xxxx xxxx xxxx xxxx] */
/* */
/* nice! (I'll try to use 26 bit after the point sometime) */
/* */
/* 28.11.89 found IFF-Library on Fish #173. save picture option */
/* added. */
/* */
/* 04.12.89 improved assembly program */
/* */
/* 07.12.89 slight optimization in recursion scheme */
/* */
/* 09.12.89 added input requester */
/* */
/* 21.07.90 review for Aztek-C5.0a */
/* */
/* 23.09.90 print option added (color printers) */
/* */
/* 25.09.90 added color requester */
/* */
/* 27.09.90 optimization of assembly program */
/* */
/* 15.11.90 review for SAS C5.10 */
/* */
/* 19.11.90 added a little retrying in case of an error by closing */
/* screens. Might recover some problems with Amigas short */
/* on memory or when really *BIG* screens are requested. */
/* */
/* 25.11.90 added s'more source code comments and translated all */
/* strings from german to english */
/* */
/* 30.01.91 removed a bug causing to save no colormap along with a */
/* picture */
/* */
/* 01.02.91 removed a bug doing strange things while colorcycling */
/* pictures with more than 5 BitPlanes */
/* */
/* 01.02.91 added configuration facilities */
/* */
/* 17.04.91 removed a bug preventing the "Multitasking OFF" to work */
/* */
/* 18.04.91 some cast - operators added in "printersupport.h" to */
/* compile without warnings. */
/* */
/* 08.06.91 added 68030/68881 support */
/* */
/* 09.06.91 replaced lattice fp by fast floating point functions */
/* (faster only if FLOAT is used. shorter object, though) */
/************************************************************************/
/* W A R N I N G ! ! ! */
/* */
/* From now on ALL versions of Apfelkiste will need KS 2.0 and the new */
/* set of include files. This applies to version 28 and above. */
/************************************************************************/
/* */
/* 12.06.91 switched to 2.0 at last. removed ARP routines, not */
/* because they're bad (THEY AREN'T!), but because of */
/* naming conflicts of arp.h to 2.0 include files. */
/* */
/* 12.06.91 added some all *new* facilities: */
/* o automatic overscan adaption */
/* o autoscrolling screen */
/* */
/* 22.07.91 2.0 style gadgets provided */
/* */
/* 23.07.91 located a bug in SAS's fscanf() (!!!), %hx does NOT */
/* read 16 Bit integers but 32 Bit longs. Thus lead into */
/* a strange error that occurred with pictures >3 */
/* bitplanes only: all colors above #8 are set to 0(black) */
/* Fixed by scanning into a temporary long first. */
/* */
/* 23.10.91 changed names of OpenIFF() and CloseIFF() to xOpenIFF() */
/* and xCloseIFF() for KS 2.0 include file compatibility */
/* */
/* updated docs for inclusion in AmigaLibDisk pool */
/* */
/* last-minute review for SAS C5.10b */
/************************************************************************/
/* -------------------------------------------------------------------- */
/* Some defininitions to take advantage of Lattice's LSR-code: */
/* -------------------------------------------------------------------- */
long _stack = 20000; /* Stack space for this task */
char *_procname = "Apfelkiste"; /* Name of process created */
long _priority = 0; /* Process priority */
long _BackgroundIO = 0; /* No stdio required */
/* -------------------------------------------------------------------- */
#define APFEL_VERSION "30"
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <graphics/gfx.h>
#include <graphics/gfxmacros.h>
#include <libraries/iff.h>
#include <libraries/asl.h>
#include <libraries/color.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/asl.h>
#include <proto/gadtools.h>
#include <printersupport.h>
#include <clib/macros.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <mffp.h>
#include <math.h>
#include "Apf0.h"
#include "Apf2.h"
/* -------------------------------------------------------------------- */
/* Prototypes for the functions in the other modules */
/* -------------------------------------------------------------------- */
void FixPoint( double rmin, double rmax, double imin, double imax,
double dx, double dy,
int maxiter, double divergenz, int gx, int gy, int depth);
void __regargs Apfel_Alert(long number);
void __regargs Activate_Gadget(struct Window *w, USHORT ID);
void __regargs Apfel_FLOAT(int x1, int y1, int x2, int y2);
long Iter_FLOAT(double r, double i);
void FreeGads(void);
struct Gadget *InitGads(struct Screen *scr);
/* --------------------------------------------------------------------- */
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct IFFBase *IFFBase;
struct Library *AslBase;
struct ColorBase *ColorBase;
struct Library *GadToolsBase;
struct Screen *s;
struct Window *w, *u;
struct RastPort *rp, *up;
struct ViewPort *vp;
struct Gadget *glist;
char DefBuf_REAL0[40];
char DefBuf_REAL1[40];
char DefBuf_IMAG0[40];
char DefBuf_IMAG1[40];
char DefBuf_MAXITER[40];
char DefBuf_DIV[40];
char DefBuf_XSIZE[40];
char DefBuf_YSIZE[40];
char DefBuf_DEPTH[40];
extern long SelNo_TASK;
extern long SelNo_CYCLE;
extern char *Buf_REAL0;
extern char *Buf_REAL1;
extern char *Buf_IMAG0;
extern char *Buf_IMAG1;
extern char *Buf_MAXITER;
extern char *Buf_DIV;
extern char *Buf_XSIZE;
extern char *Buf_YSIZE;
extern char *Buf_DEPTH;
extern char *DefText_REAL0;
extern char *DefText_REAL1;
extern char *DefText_IMAG0;
extern char *DefText_IMAG1;
extern char *DefText_MAXITER;
extern char *DefText_DIV;
extern char *DefText_XSIZE;
extern char *DefText_YSIZE;
extern char *DefText_DEPTH;
int cycle, task = TRUE;
APTR IFFfile = NULL;
struct FileRequester *FReq;
union printerIO *request;
struct MsgPort *printerPort;
int gx, gy, xsize, ysize, depth, hide;
short maxcol;
int maxiter;
double divergenz, rmin, rmax, imin, imax, dx, dy;
/* -------------------------------------------------------------------- */
/* All the stuff needed to comfortably get IntuitionMessages */
/* -------------------------------------------------------------------- */
ULONG CLASS, CODE, GAD_ID;
APTR ADDR;
struct IntuiMessage *Message = NULL;
ULONG GetMessage(struct Window *MW)
{
CLASS = CODE = 0;
ADDR = NULL;
if ( Message = (struct IntuiMessage *) GetMsg(MW->UserPort) ) {
CLASS = Message->Class;
CODE = Message->Code;
ADDR = Message->IAddress;
ReplyMsg((struct Message *) Message);
}
return CLASS;
}
ULONG GT_GetMessage(struct Window *MW)
{
CLASS = CODE = GAD_ID = 0;
ADDR = NULL;
if ( Message = GT_GetIMsg(MW->UserPort) ) {
CLASS = Message->Class;
CODE = Message->Code;
ADDR = Messa